package com.atguigu.paymentdemo.controller;

import com.atguigu.paymentdemo.entity.Product;
import com.atguigu.paymentdemo.mapper.ProductMapper;
import com.atguigu.paymentdemo.service.ProductService;
import com.atguigu.paymentdemo.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author longge
 * @Title:  商品
 * @Description:    商品
 * @date 2023/2/4 22:52
 */
@Api(tags = "商品管理")
@RestController
@RequestMapping("/api/product")
public class ProductController {

    @Autowired
    private ProductService productService;


    @ApiOperation("测试接口")
    @GetMapping("/test")
    public R test(){
        productService.test();
        System.out.println("");
        return R.ok()
                .data("message","hello world")
                .data("now",new Date());
    }

    @ApiOperation("查询商品列表")
    @GetMapping("/list")
    public R list(){
        List<Product> list = productService.list();
        return R.ok().data("productList",list);
    }
}
